package com.jhx.video.store

import com.jhx.common.http.ApiManager
import com.jhx.common.http.HttpRequest
import com.jhx.common.http.ResponseCallback
import com.jhx.common.model.Photos
import com.jhx.video.service.VideoService

/**
 *
 *
 * @author Jack 2018-03-27 11:02
 */
class PhotoPresenterImpl : Contract.PhotoPresenter() {

    override fun getPhoto(nowPage: Int, pageSize: Int) {
        mView?.showLoading()
        val call = ApiManager.get().getApiService(VideoService::class.java).getPhotos("$nowPage", "$pageSize")
        HttpRequest.getRequest().autoRecycle(mView?.getContext()).start(call, object : ResponseCallback<Photos>() {

            override fun onSuccess(url: String, data: Photos?) {
                mView?.hideLoading()
                mView?.getPhotoSuccess(data)
            }

            override fun onError(url: String?, errorCode: Int, errorMsg: String?) {
                super.onError(url, errorCode, errorMsg)
                mView?.hideLoading()
            }
        })
    }

    override fun recycler() {

    }
}